package com.baoyouqun.controller.weixin;

import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baoyouqun.base.PageResponse;
import com.baoyouqun.domain.Query.UserPointsRecordQuery;
import com.baoyouqun.domain.VO.UserPointsRecordVO;
import com.baoyouqun.service.UserPointsRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("wx/userPointsRecord")
@Api(tags = "用户积分变动记录表管理接口")
public class WxUserPointsRecordController {

    @Resource
    private UserPointsRecordService userPointsRecordService;

    @GetMapping("page")
    @ApiOperation("分页查询用户积分变动记录表")
    public PageResponse<UserPointsRecordVO> page(UserPointsRecordQuery query) {
        String userId = StpUtil.getLoginIdAsString();
        query.setUserId(userId);
        IPage<UserPointsRecordVO> page = userPointsRecordService.pageVo(query);
        return PageResponse.of(page.getRecords(), page.getTotal(), page.getCurrent(), page.getSize());
    }
}